﻿using System;
using System.Collections.Generic;
using RN.ERP.BLL;
using RN.ERP.DTO;
using Newtonsoft.Json;
using BllType = RN.ERP.BLL.BllType;
using Fly.Common.WorkFlow;
using System.ServiceModel.Activation;

namespace RN.ERP
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“BasicService”。
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class BasicService : IBasicService
    {
        private BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, Utilities.GetDbType());

        public string DoLoginWithAuthority(string userName, string password, string dogId, string groupType, string areaCode, string appId)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.DoLoginWithAuthority(userName, password, dogId, groupType, appId);
        }

        public string DoLoginWithUGuid(string userGuid, string areaCode, string appId)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.DoLoginWithAuthority(userGuid, appId);
        }

        public string DoLogin(string userName, string password, string userType, string areaCode, string systemid)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.DoLogin(userName, password, userType, systemid);
        }

        public string GetUserInfo(string userguid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetUserInfo(userguid, areaCode);
        }

        /// <summary>
        /// 根据key号获取用户信息，含用户是否主管
        /// </summary>
        /// <param name="dogid"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string GetUserInfobyDogID(int dogid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetUserInfobyDogID(dogid, areaCode);
        }
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="userGuid"></param>
        /// <param name="newPwd"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public bool ResetPassword(string userGuid, string newPwd, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            Guid guid = new Guid();
            Guid.TryParse(userGuid, out guid);
            return basicBll.ResetPassword(guid, newPwd, areaCode);
        }

        /// <summary>
        /// 重置组织机构代码
        /// </summary>
        /// <param name="userGuid"></param>
        /// <param name="newPwd"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public bool ResetOrginazationCode(string userGuid, string newCode, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            Guid guid = new Guid();
            Guid.TryParse(userGuid, out guid);
            return basicBll.ResetOrginazationCode(guid, newCode, areaCode);
        }

        /// <summary>
        /// 通过企业组织机构代码获取企业信息
        /// </summary>
        /// <param name="OrginazationCode"></param>
        /// <returns></returns>
        public string GetCompanyInfo(string OrginazationCode, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            List<DTO.Tb_Corp_CompanyInfo> list = basicBll.GetCompanyInfo(OrginazationCode, areaCode);
            return JsonConvert.SerializeObject(list);
        }
        public string GetDictionaryTitleByCode(string code, string type, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetDictionaryTitleByCode(code, type, areaCode);
        }

        public string GetDictionary(string type, string condition, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetDictionary(type, condition, areaCode);
        }

        public string BindDdlistArea(string areainfo, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            a_AreaSSQ areainfolist = JsonConvert.DeserializeObject<a_AreaSSQ>(areainfo);
            return JsonConvert.SerializeObject(basicBll.BindDdlistArea(areainfolist, areaCode));
        }

        public string GetLogs(string objectId, string functionType, string startDate, string endDate, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            throw new NotImplementedException();
        }

        public string DoLoginWithDog(string userName, string password, string dogId, string userType, string areaCode, string systemid)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.DoLogin(userName, password, dogId, userType, systemid);
        }

        public string GetChangeItems(string changeType, string appId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChangeItems(changeType, appId, areaCode);
        }

        public string GetBeforeChangeValue(string changeItem, string areaCode, params string[] parameters)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetBeforeChangeValue(changeItem, areaCode, parameters);
        }

        public string GetBindChangeValue(string changeItem, string areaCode, string[] parameters)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetBindChangeValue(changeItem, areaCode);
        }


        /// <summary>
        /// 添加变更申请
        /// </summary>
        /// <param name="changeInfo"></param>
        /// <returns></returns>
        public string AddChange(
            string changeSetInfo,
            string changeInfo,
            string changeType,
            string userGuid,
            string userRole,
            string userName,
            string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.AddChange(changeSetInfo, changeInfo, changeType, userGuid, userRole, userName, areaCode);
        }

        /// <summary>
        /// 提交变更申请集合
        /// </summary>
        /// <param name="changeIds"></param>
        /// <returns></returns>
        public string SubmitChange(
            string changeIds,
            string changeType,
            string userGuid,
            string userRole,
            string userName,
            string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.SubmitChange(changeIds, changeType, userGuid, userRole, userName, areaCode);
        }

        public string EditChange(
            string changeSetInfo,
            string changeInfo,
            string changeType,
            string userGuid,
            string userRole,
            string userName,
            string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.EditChange(changeSetInfo, changeInfo, changeType, userGuid, userRole, userName, areaCode);
        }

        public string DeleteChange(
            string changeId,
            string changeType,
            string userGuid,
            string userRole,
            string userName,
            string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.DeleteChange(changeId, changeType, userGuid, userRole, userName, areaCode);
        }

        public string CheckChange(string changeSetId, string userRole, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.CheckChange(changeSetId, userRole, areaCode);
        }
        /// <summary>
        /// 变更审核
        /// </summary>
        /// <param name="changeId"></param>
        /// <param name="flowCode"></param>
        /// <param name="isFinal"></param>
        /// <param name="userGuid"></param>
        /// <param name="userRole"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public string AuditChange(string changeId, string flowCode, string description, bool isFinal, string userGuid, string userRole, string userName, string areaCode)
        {

            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.AuditChange(changeId, flowCode, description, isFinal, "", userGuid, userRole, userName, areaCode);
        }

        public string GetChanges(string changeType, string corpUserGuid, string flowCode, string condition, int pageIndex, int pageSize, out int count, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChanges(changeType, corpUserGuid, flowCode, condition, pageIndex, pageSize, out count, areaCode);
        }

        public string AuditLogs(string objectId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.AuditLogs(objectId, areaCode);
        }

        public string GetChangeEmpList(string conditions, int pageCount, int pageSize)
        {
            return JsonConvert.SerializeObject(basicBll.GetChangeEmpList(conditions, pageCount, pageSize));
        }
        public int GetChangeEmpCount(string conditions)
        {
            return basicBll.GetChangeEmpCount(conditions);
        }
        /// <summary>
        /// 返回变更项需要上传的图片
        /// </summary>
        /// <returns></returns>
        public string GetChangeItemUploadImg(string uploadID, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChangeItemUploadImg(uploadID, areaCode);
        }
        #region 人员资格相关
        public List<DTO.tb_Emp_TitleType> GetPsnQualLevelByType(int nid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetPsnQualLevelByType(nid, areaCode);
        }
        public List<DTO.a_Speciality> GetPsnspecialtyByQualLType(int nid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetPsnspecialtyByQualLType(nid, areaCode);
        }
        /// <summary>
        /// 根据资格guid获取资格明细
        /// </summary>
        /// <param name="qulaiguid"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string GetPersonQualityByGid(string qulaiguid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            //return basicBll.GetPersonQualityByGid(qulaiguid, areaCode);
            return JsonConvert.SerializeObject(basicBll.GetPersonQualityByGid(qulaiguid, areaCode));

        }
        #endregion 人员资格相关

        #region 企业资质相关
        public List<DTO.KeyValue> GetCorpQualLevByUserGuid(int roleid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetCorpQualLevByUserGuid(roleid, areaCode);
        }
        public virtual List<DTO.CorpKindKeyAndValue> GetCorpQualTypesByUserGuid(int roleid, int classid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetCorpQualTypesByUserGuid(roleid, classid, areaCode);
        }
        public virtual string GetCorpQualByGuid(string guid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            //return basicBll.GetCorpQualByGuid(guid, areaCode);
            return JsonConvert.SerializeObject(basicBll.GetCorpQualByGuid(guid, areaCode));
        }
        #endregion 企业资质相关

        public string GetQualitiesDic(string rootCode, string parentId)
        {
            return JsonConvert.SerializeObject(basicBll.GetQualitiesDic(rootCode, parentId));
        }
        public string GetQualitiesDicAll(string rootCode, string parentId, string childRootCode)
        {
            return JsonConvert.SerializeObject(basicBll.GetQualitiesDicAll(rootCode, parentId, childRootCode));
        }
        public string GetCity()
        {
            return JsonConvert.SerializeObject(basicBll.GetCity());
        }
        public string GetQu(string code)
        {
            return JsonConvert.SerializeObject(basicBll.GetQu(code));
        }
        public string GetAddress(string code)
        {
            return basicBll.GetAddress(code);
        }

        public string GetFuncPageMapping(string appId)
        {
            return JsonConvert.SerializeObject(basicBll.GetFuncPageMapping(appId));
        }

        public string GetNextFlowCode(string roleId,
            string manager,
            string areaCode,
            string classId,
            string flowCode,
            OptType optType)
        {
            return JsonConvert.SerializeObject(basicBll.GetNextFlowCode(roleId, manager, areaCode, classId, flowCode, optType));
        }

        public string GetFlowCodeTitle(string areaCode, string classId, string flowCode)
        {
            return basicBll.GetFlowCodeTitle(areaCode, classId, flowCode);
        }
        public string GetChangeDetails(string changeType, int changeSetId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChangeDetails(changeType, changeSetId, areaCode);
        }
        #region 获取变更列表 2013-11-4 毛凯
        public string GetChangeRecords(string condition,
            int pageNum,
            int pageSize,
            string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChangeRecords(condition, pageNum, pageSize, areaCode);
        }

        public int GetChangeRecordsCount(string condition, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChangeRecordsCount(condition, areaCode);
        }
        #endregion

        /// <summary>
        /// 取得统计--企业和人员类型
        /// </summary>
        /// <param name="rootCode"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string GetSysStaticSettings(string rootCode, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetSysStaticSettings(rootCode, areaCode);
        }

        #region 根据用户角色获取所有流程状态
        public string GetAllFlowStatus(string areaCode, string roleId, string classId, out string msg)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetAllFlowStatus(areaCode, roleId, classId, out msg);
        }

        public string GetAllStatusFlowCodesByTitle(string roleID, string areaCode, string classId, out string msg)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetAllStatusFlowCodesByTitle(roleID, areaCode, classId, out msg);
        }

        public string GetAllBusinessStatusAndProcessing(string roleID, string areaCode, string classId, out string msg, bool contiansAll = false)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetAllBusinessStatusAndProcessing(roleID, areaCode, classId, out msg, contiansAll);
        }
        public string GetAllBusinessStatus(string areaCode, string classId, out string msg)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetAllBusinessStatus(areaCode, classId, out msg);
        }

        public int CheckCreater(string areaCode, string classId, string roleID, out string msg)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.CheckCreater(areaCode, classId, roleID, out msg);
        }
        #endregion


        public bool IsAppRightValid(int AppID, Guid UserGuid, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.IsAppRightValid(AppID, UserGuid);
        }
        /// <summary>
        /// 根据地区编号取得地区名称
        /// </summary>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string GetAreaCodeTitle(string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.GetAreaCodeTitle(areaCode);
        }

        #region 即时通讯

        public bool Send(DTO.T_Msg_SentMsg msg)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.SendMsg(msg);
        }

        public List<DTO.T_Msg_SentMsg> GetMsgs(string Receiver, string Sender, int AppID, DateTime? LastSearchTime
            , Boolean? IsRead, bool DoRead, string AreaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.GetMsgs(Receiver, Sender, AppID, LastSearchTime, IsRead, DoRead, AreaCode);
        }

        public string GetMsgUser(string areaCode, List<int> classIds, List<int> manageRoleIds)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.GetMsgUser(areaCode, classIds, manageRoleIds);
        }

        public bool MsgsDelete(string CurrentUser, int AppID, string msgIds)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.MsgsDelete(CurrentUser, AppID, msgIds);
        }

        public bool SendChat(T_Chat_ChatInfo chatInfo)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.SendChat(chatInfo);
        }

        public List<T_Chat_ChatInfo> GetChatInfos(string Receiver, string Sender, int AppID
            , DateTime? LastSearchTime, bool? IsRead, bool DoRead, string AreaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.GetChatInfos(Receiver, Sender, AppID, LastSearchTime, IsRead, DoRead, AreaCode);
        }

        public List<DTO.T_Chat_ChatInfo> GetChatHistory(string Receiver, string Sender, int AppID, DateTime? StartTime
            , DateTime? EndTime, string AreaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.GetChatHistory(Receiver, Sender, AppID, StartTime, EndTime, AreaCode);
        }

        public List<T_Chat_ChatInfo> GetChatBrief(string Receiver, int MaxCount, int AppID)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.GetChatBrief(Receiver, MaxCount, AppID);
        }

        public List<T_Msg_SentMsg> GetLetterBrief(string Receiver, int MaxCount, int AppID)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, string.Empty);
            return basicBll.GetLetterBrief(Receiver, MaxCount, AppID);
        }

        #endregion

        #region 获取系统配置
        public string GetApplicationConfig(string appId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.GetApplicationConfig(appId));
        }
        #endregion

        public string GetSysDicts(string rootCode, string parentSID, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.GetSysDicts(rootCode, parentSID));
        }

        public string DoExpertLogin(string idNum, string passWord, string appId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.DoExpertLogin(idNum, passWord, appId));
        }
        #region 老专家登陆验证
        public string CheckEmpInfo(string CerdentialsCode, string phone, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.CheckEmpInfo(CerdentialsCode, phone));
        }
        #endregion

        public string GetExpertDBList()
        {
            return JsonConvert.SerializeObject(basicBll.GetExpertDBList());
        }
        public virtual string GetExpertDBName(string code)
        {
            return basicBll.GetExpertDBName(code);
        }

        /// <summary>
        /// 以手机为唯一标识修改密码
        /// </summary>
        /// <param name="phoneNum">手机号</param>
        /// <param name="newPwd">新密码</param>
        /// <returns>是否成功</returns>
        public bool ResetPwdByTel(string phoneNum, string newPwd)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, "");
            return basicBll.ResetPwdByTel(phoneNum, newPwd);
        }

        #region 新变更方法

        /// <summary>
        /// 取得变更项选择下拉列表
        /// </summary>
        /// <param name="changeType"></param>
        /// <param name="appId"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string GetChangeItemsNew(string changeType, int parentId, string appId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChangeItemsNew(changeType, parentId, appId, areaCode);
        }
        /// <summary>
        /// 取得变更内容列表
        /// </summary>
        /// <param name="changItemId"></param>
        /// <returns></returns>
        public string GetChangItemsValues(string changItemId, string objectId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.GetChangItemsValues(changItemId, objectId, areaCode));
        }
        /// <summary>
        /// 取得变更集及其包含的变更项
        /// </summary>
        /// <param name="changeSetId"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string GetChangeDetailsNew(int changeSetId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.GetChangeDetailsNew(changeSetId, areaCode));
        }

        /// <summary>
        /// 根据id或父id取得一级变更项或二级变更项列表
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="id"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string GetChangeItemsForIDNew(int changItemId, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetChangeItemsForIDNew(changItemId, areaCode);
        }
        /// <summary>
        /// 取得变更前值
        /// </summary>
        /// <param name="changeItem"></param>
        /// <param name="appId"></param>
        /// <param name="areaCode"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public string GetBeforeChangeValueNew(string changeItemId, string areaCode, params string[] parameters)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.GetBeforeChangeValueNew(changeItemId, areaCode, parameters);
        }

        /// <summary>
        /// 取得变更后值
        /// </summary>
        /// <param name="changeItem"></param>
        /// <param name="appId"></param>
        /// <param name="areaCode"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public string GetBindChangeValueNew(string changeItemId, string areaCode, params string[] parameters)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.GetBindChangeValueNew(changeItemId, areaCode, parameters));
        }

        /// <summary>
        /// 添加变更申请
        /// </summary>
        /// <param name="changeInfo"></param>
        /// <returns></returns>
        public string AddChangeNew(string changeSetInfo, string changeInfo, int codeType, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.AddChangeNew(changeSetInfo, changeInfo, codeType, areaCode));
        }

        /// <summary>
        /// 修改变更申请
        /// </summary>
        /// <param name="changeSetInfo"></param>
        /// <param name="changeInfo"></param>
        /// <param name="userGuid"></param>
        /// <param name="userName"></param>
        /// <param name="codeType"></param>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public string EditChangeNew(string changeSetInfo, string changeInfo, string roleId, int codeType, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.EditChangeNew(changeSetInfo, changeInfo, roleId, codeType, areaCode));
        }

        /// <summary>
        /// 变更申请上报
        /// </summary>
        /// <param name="changeIds"></param>
        /// <returns></returns>
        public string SubmitChangeNew(string changeIds, string changeSetInfo, string changeInfo, string userGuid, string userName, string roleId, int codeType, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return JsonConvert.SerializeObject(basicBll.SubmitChangeNew(changeIds, changeSetInfo, changeInfo, userGuid, userName, roleId, codeType, areaCode));
        }

        #endregion

        public string GetChangeSetRecordList(out int cnt,
        int pageNo,
        int pageSize,
        string conditions,
        string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            var result = basicBll.GetChangeSetRecordList(out cnt, pageNo, pageSize, conditions, areaCode);
            return JsonConvert.SerializeObject(result);
        }

        #region 获取条款
        //条款查询
        public string GetEScoreType(int bKind, int bType, string Areacode, string condtion)
        {
            return basicBll.GetEScoreType(bKind, bType, Areacode, condtion);
        }

        public string Gete_ScoreTypeByTypeID(int typeid)
        {
            return JsonConvert.SerializeObject(basicBll.Gete_ScoreTypeByTypeID(typeid));
        }
        //子条款查询
        public string GetEScore(int typeID, string condtion)
        {
            return basicBll.GetEScore(typeID, condtion);
        }

        public string GetEScoreByID(int ID)
        {
            return JsonConvert.SerializeObject(basicBll.GetEScoreByID(ID));
        }

        #endregion

        #region 烟台门户管理后台登录
        public string DoBackGroundLogin(string userName, string password, string areaCode)
        {
            BaseBasicBLL basicBll = (BaseBasicBLL)BllFactory.CreateBll(BllType.Basic, areaCode);
            return basicBll.DoBackGroundLogin(userName, password);
        }
        #endregion
    }
}
